﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Awsc.DataAcquisitionSys.Core.Common
{
    public class ArgumentAssert
    {
        public static void NotNull(object value, [CallerArgumentExpression("value")]string caller=null)
        {
            if (value == null)
            {
                throw new ArgumentNullException(caller, $"{caller} cannot be null.");
            }
        }

        public static void GreaterThanZero(double value, [CallerArgumentExpression("value")] string caller = null)
        {
            if (value <=0)
            {
                throw new ArgumentNullException(caller, $"{caller} cannot be null.");
            }
        }

        public static void NotNullOrEmpty(string value, [CallerArgumentExpression("value")] string caller = null)
        {
            if (string.IsNullOrWhiteSpace(value))
            {
                throw new ArgumentNullException(caller, $"{caller} cannot be null or emtpy.");
            }
        }

        public static void NotNullOrEmpty<T>(IEnumerable<T> value, [CallerArgumentExpression("value")] string caller = null)
        {
            if (value == null || !value.Any())
            {
                throw new ArgumentNullException(caller, $"{caller} cannot be null or empty.");
            }
        }
    }
}
